﻿using System;
using AzureDiagMon.Common.Dtos;
using AzureDiagMon.Common.Helpers.Azure;
using AzureDiagMon.Common.Mvvm;

namespace AzureDiagMon.ViewModels.Entities
{
    public class WadLogEntryRowViewModel : EntityViewModel<WadLogEntryDto>
    {
        private readonly bool isLocalTimeMode;

        public WadLogEntryRowViewModel(WadLogEntryDto entity)
            : this(entity, true) { }

        public WadLogEntryRowViewModel(WadLogEntryDto entity, bool isLocalTimeMode)
            : base(entity)
        {
            this.isLocalTimeMode = isLocalTimeMode;
        }

        public DateTime Timestamp
        {
            get { return Entity.Timestamp; }
        }

        public string Message
        {
            get { return Entity.Message.Replace("\r", " ").Replace("\n", ""); }
        }

        public string Role
        {
            get { return Entity.Role; }
        }

        public string RoleInstance
        {
            get { return Entity.RoleInstance; }
        }

        public int EventId
        {
            get { return Entity.EventId; }
        }


        public int Level
        {
            get
            {
                return Entity.Level;
            }
        }

        public DateTime EventTime
        {
            get
            {
                return isLocalTimeMode
                           ? Entity.EventTickCount.ToLocalDateTime()
                           : Entity.EventTickCount.ToDateTime();
            }
        }

    }
}
